package vn.com.vega.music.view.adapter;

import java.util.List;

import vn.com.vega.chacha.R;
import vn.com.vega.music.objects.Playlist;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListPlaylistPersonalMusicAdapter extends BaseAdapter {
	private LayoutInflater mInflater;
	private List<Playlist> mListPlaylist;
	public int numberSelect = 0;

	public ListPlaylistPersonalMusicAdapter(Context ctx, List<Playlist> list) {
		mListPlaylist = list;
		if (list == null || list.size() == 0) {
			return;
		}
		mInflater = (LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mListPlaylist.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mListPlaylist.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		final ViewHolder hoder;
		if (convertView == null) {
			convertView = mInflater.inflate(
					R.layout.lv_item_playlist_personal_music, null);
			hoder = new ViewHolder();
			hoder.playlistName = (TextView) convertView
					.findViewById(R.id.tv_playlist_name);
			convertView.setTag(hoder);
		} else {
			hoder = (ViewHolder) convertView.getTag();
		}

		Playlist playlist = (Playlist) getItem(position);
		hoder.playlistName.setText(playlist.title + " (" + playlist.total_song
				+ ")");

		return convertView;
	}

	static class ViewHolder {
		TextView playlistName;
	}

}
